﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DynaPrecision.Numerical
{
	using FunctionAnalysis;
	public class NumericalDifferentialOperator<TResult, TInput> : IFunction<TInput, TResult>
	{
		public TInput Resolution { get; set; }
		public Func<TInput, TResult> FunctorToBeOperated { get; set; }

		public NumericalDifferentialOperator()
		{
			Resolution = DefaultValueProvider<TInput>.GetDefaultResolution();
		}

		#region IFunction<TInput,TResult> Members

		public Func<TInput, TResult> Functor
		{
			get
			{
				return x =>
				{
					dynamic _x = x;
					dynamic L = FunctorToBeOperated(_x - Resolution), R = FunctorToBeOperated(_x + Resolution);
					return (R - L) / 2 / Resolution;
				};
			}
		}

		public IFunction<TInput, TResult> Derivative
		{
			get { throw new NotImplementedException(); }
		}

		public IFunction<TInput, TResult> Integral
		{
			get { throw new NotImplementedException(); }
		}

		#endregion
	}
}
